var app = getApp();

Page({
    data: {},
    onLoad: function(e) {
        app.setNavigationBarColor(this), this.refresh();
    },
    isinarray: function(e, t) {
        for (var n = 0; n < e.length; n++) if (t === e[n].name) return !0;
        return !1;
    },
    refresh: function(e) {
        var t = this, n = wx.getStorageSync("userInfo").id, o = wx.getStorageSync("userInfo").name;
        console.log(n), app.util.request({
            url: "entry/wxapp/HxCode",
            cachetime: "0",
            data: {
                user_id: n
            },
            success: function(e) {
                console.log(e), t.setData({
                    hx_code: e.data
                });
            }
        }), app.util.request({
            url: "entry/wxapp/HxList",
            cachetime: "0",
            data: {
                user_id: n
            },
            success: function(e) {
                console.log(e), 0 == t.isinarray(e.data, o) && app.util.request({
                    url: "entry/wxapp/AddVerification",
                    cachetime: "0",
                    data: {
                        user_id: n,
                        hx_id: n
                    },
                    success: function(e) {
                        console.log(e), 1 == e.data && t.refresh();
                    }
                }), t.setData({
                    hx_list: e.data
                });
            }
        });
    },
    delete_hx: function(e) {
        var t = this, n = e.currentTarget.dataset.id;
        wx.showModal({
            title: "",
            content: "确认删除此核销员？",
            success: function(e) {
                e.confirm ? (console.log("用户点击确定"), app.util.request({
                    url: "entry/wxapp/DelVerification",
                    cachetime: "0",
                    data: {
                        id: n
                    },
                    success: function(e) {
                        console.log(e), t.refresh();
                    }
                })) : e.cancel && console.log("用户点击取消");
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {}
});